<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>

<?php 
	$task = $this->uri->segment(4,'');
	//$escort_id = intval($this->input->get('escort_id',TRUE));
	//$per_page = intval($this->input->get('per_page',TRUE));
	//$ESCORT = $this->escort_entity->init('id',$escort_id);
	/*
	if($ESCORT){
		if($ESCORT->getUserId() != getAccountUserId()){
			show_404();
		}
		breadcumb(4, array($ESCORT->getEscortName(),'#'));
		$_SESSION['agent_escort_id'] = $ESCORT->getId();
	}else{
		breadcumb(4, array());
		unset($_SESSION['agent_escort_id']);
	}
	*/
	//unset($_SESSION['agent_escort_id']);
	$href = '';// "?escort_id=".$escort_id;//."&per_page=".$per_page;
	$task_array = array('dashboard', 'personal_info'
	//, 'appareance', 'services', 'rates', 'contact_info', 'pictures_videos', 'add_new'
	);
 
?> 
<div id="content-left">
	<?php $this->load->view('agent/escorts_list_page'); ?>
	<div class="clear"></div>
	
	<div id="personal-tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
		<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
			<li id="personal_dashboard" class="ui-state-default ui-corner-top ui-tabs-first-non-selected"><a href="<?php echo site_url_lang('agent/my_profile/dashboard'.$href);?>" ><?php echo language_translate('profile_page_dashboard');?></a></li>
			<li id="personal_personal_info" class="ui-state-default ui-corner-top"><a href="<?php echo site_url_lang('agent/my_profile/personal_info'.$href);?>" ><?php echo language_translate('profile_page_personal_info');?></a></li>
		<!-- 	
			<li id="personal_appareance" class="ui-state-default ui-corner-top"><a href="<?php echo site_url('agent/profile/appareance'.$href);?>" ><?php echo language_translate('profile_page_appareance');?></a></li>
			<li id="personal_services" class="ui-state-default ui-corner-top"><a href="<?php echo site_url('agent/profile/services'.$href);?>"><?php echo language_translate('profile_page_services');?></a></li>
			<li id="personal_rates" class="ui-state-default ui-corner-top"><a href="<?php echo site_url('agent/profile/rates'.$href);?>"><?php echo language_translate('profile_page_rates');?></a></li>
			<li id="personal_contact_info" class="ui-state-default ui-corner-top"><a href="<?php echo site_url('agent/profile/contact_info'.$href);?>"><?php echo language_translate('profile_page_contact_info');?></a></li>
			<li id="personal_pictures_videos" class="ui-state-default ui-corner-top"><a href="<?php echo site_url('agent/profile/pictures_videos'.$href);?>"><?php echo language_translate('profile_page_pictures_videos');?></a></li>
		-->
			<li id="personal_end_tab" class="ui-state-default ui-corner-top ui-tabs-last-non-selected"><a href="#">&nbsp;</a></li>
		</ul>
		
		<?php if($task === 'dashboard' OR !in_array($task, $task_array)):?>
			<div id="tabs-1" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
				<?php $this->load->view('agent/agent_account/dashboard'); ?>
			</div>
		<?php endif; ?>
		
		<?php if($task === 'personal_info' ):?>
			<div id="tabs-2" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
				<?php $this->load->view('agent/agent_account/personal_info');?>
			</div>
		<?php endif; ?>	
		
		 
	</div>
</div>

<?php $this->load->view('agent/right_nav'); ?>
	
<div class="clear"></div>
 
		
<script type="text/javascript">
	var PROFILE_TASK = '<?php echo $task;?>';
	
	$(document).ready(function() {
		$('#personal_dashboard,#personal_personal_info,#personal_appareance,#personal_services,#personal_rates,#personal_contact_info,#personal_pictures_videos,#personal_end_tab').removeClass('ui-tabs-selected ui-state-active');
		switch(PROFILE_TASK){
			case 'dashboard':
			default:
				$('#personal_dashboard').removeClass('ui-tabs-first-non-selected').addClass('ui-tabs-selected ui-state-active');
				$('#personal_personal_info').addClass('ui-tabs-next-to-selected');
				break;
			case 'personal_info':
				$('#personal_personal_info').addClass('ui-tabs-selected ui-state-active');
				$('#personal_appareance').addClass('ui-tabs-next-to-selected');
				break;
				/*		
			case 'appareance':
				$('#personal_appareance').addClass('ui-tabs-selected ui-state-active');
				$('#personal_services').addClass('ui-tabs-next-to-selected');
				break;	
			case 'services':
				$('#personal_services').addClass('ui-tabs-selected ui-state-active');
				$('#personal_rates').addClass('ui-tabs-next-to-selected');
				break;	
			case 'rates':
				$('#personal_rates').addClass('ui-tabs-selected ui-state-active');
				$('#personal_contact_info').addClass('ui-tabs-next-to-selected');
				break;	
			case 'contact_info':
				$('#personal_contact_info').addClass('ui-tabs-selected ui-state-active');
				$('#personal_pictures_videos').addClass('ui-tabs-next-to-selected');
				break;	
			case 'pictures_videos':
				$('#personal_pictures_videos').addClass('ui-tabs-selected ui-state-active');
				$('#personal_end_tab').addClass('ui-tabs-next-to-selected');
				break;	*/
		} 
		
		var options = { 
			beforeSubmit:  validateB4SubmitSendMessage,  
			success:       processAfterRespondingSendMessage   
		};
		$("#submit_send_message").live("submit",function(e){
			e.preventDefault(); // <-- important
			$(this).ajaxSubmit(options);
			return false;
		});	
		
		$('#escort_add').click(function(){
			queryurl(BASE_URI+'agent/profile/add_new');
		});
	});	
	
	function open_question_dialog(user_id){
		$('#greyDiv').removeClass('hidden');
		$.post(BASE_URI+'agent/async/load_send_message_form',{user_id:user_id},function(res){
			
			$('#hiddenElement').html(res);
			$('#hiddenElement').dialog(
				{
					 width: 550,
					 height:350 ,
					 draggable: false,
					 beforeClose: function(event, ui) { 
						$('#greyDiv').addClass('hidden');
					 },
					 close: function(event, ui) { },
					 title: '<?php echo language_translate('support_label_send_message_title');?>' 
				}
			);
			$('.ui-dialog').center();
		});
	}
	
	function validateB4SubmitSendMessage(formData, jqForm, options){
		$('.loading_update_image').show();
		return true;
	}

	function processAfterRespondingSendMessage(responseText, statusText, xhr, $form) {
		$('.loading_update_image').hide();	
		res = JSON.parse(responseText);
		if(res.result == 'ok'){
			$('#wrap-delete-item').remove();
			updatedShow('message-status');
			$('.unread_number').text(res.unreadMsg);
		}else{
			debug(responseText);
		}
	}

	
</script>		
		